import requests
import execjs
import time
cookies = {
    'Hm_lvt_b1b4b9ea61b6f1627192160766a9c55c': '1698825495',
    'Hm_lpvt_b1b4b9ea61b6f1627192160766a9c55c': '1698884779',
}
timestamp = time.time()

time_tuple = time.localtime(timestamp)
headers = {
    'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
    'Accept-Language': 'zh-CN,zh;q=0.9',
    'Cache-Control': 'max-age=0',
    'Connection': 'keep-alive',
    # 'Cookie': 'Hm_lvt_b1b4b9ea61b6f1627192160766a9c55c=1698825495; Hm_lpvt_b1b4b9ea61b6f1627192160766a9c55c=1698884779',
    'Sec-Fetch-Dest': 'document',
    'Sec-Fetch-Mode': 'navigate',
    'Sec-Fetch-Site': 'none',
    'Sec-Fetch-User': '?1',
    'Upgrade-Insecure-Requests': '1',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36',
    'sec-ch-ua': '"Chromium";v="118", "Google Chrome";v="118", "Not=A?Brand";v="99"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
    'v': f'{time_tuple.tm_year}{time_tuple.tm_mon}{time_tuple.tm_mday}', #注意这个是今天是日期
}

params = {
    'pg': '0',
    'pgsz': '15',
    'total': '450',
}

response = requests.get(
    'https://jzsc.mohurd.gov.cn/APi/webApi/dataservice/query/comp/list',
    params=params,
    cookies=cookies,
    headers=headers,
)

result = execjs.compile(open('全国建筑市场监管Js.js','r',encoding='utf-8').read()).call('b',response.text)
for item in result['data']['list']:
    print(item)